<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>	
<%@ page import="jt.classic.system.role.IRole"%>
<%@ page import="jt.classic.system.user.IUser"%>
<%@ page import="jt.classic.system.ISystem"%>
<%@ page import="jt.classic.system.utils.SystemTool"%>
<%@ page import="org.limp.mine.StringTool"%>
<%@ page import="org.limp.basework.console.XSystemConfig"%>
<%@ page import="jt.classic.system.wordbook.WordBookUtil" %>
<%@ page import="jt.classic.system.wordbook.XWordbook" %>
<%@ page import="jt.classic.system.wordbook.XWordbookMain" %>
<%
  response.setHeader("Pragma","No-cache");//HTTP 1.1 
  response.setHeader("Cache-Control","no-cache");//HTTP 1.0 
  response.setHeader("Expires","0");//防止被proxy 

  String context = jt.classic.system.ISystem.getContextPath();
  
  String serverPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort();
  
  if (ISystem.invalidSesstion(request)) {
	  out.println("<script language='javascript'>");
	  out.println("alert(\"当前会话无效,请重新登录\");");
	  out.println("top.location.href = '"+context+"';");
	  out.println("</script>");
  }else{
  IUser user = ISystem.getSessionUser(request);
  String ssosessionkey = ISystem.getSSOSessionKey(user);
  
  List roleList = user.iroles();
  
  XWordbookMain wbmain = XWordbookMain.getInstance();
  List headParamList = wbmain.getWord("jspparameters");
%>
<script>
	var context = "<%=context%>";
	var serverPath = "<%=serverPath%>";
	var SSOSESSIONKEY = "<%=ssosessionkey%>";
	var userId = "<%=user.id()%>";
	var userName = "<%=user.iname()%>";
	var groupId = "<%=(user.igroup() != null ? user.igroup().id() : "")%>";
	var groupName = "<%=(user.igroup() != null ? user.igroup().iname() : "")%>";
	var IP = "<%=request.getRemoteAddr()%>";

	if(document.all){
	     setTimeout("CollectGarbage()",1000);
	}
  
  	var XSYSTEM_DB = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_DB)%>";
	var XSYSTEM_ANNEX_TRANSACTOR = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_ANNEX_TRANSACTOR)%>";
	var XSYSTEM_DATASOURCE = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_DATASOURCE)%>";
	var XSYSTEM_CHARSETNAME = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_CHARSETNAME)%>";
	var XSYSTEM_SESSIONFILTER = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_SESSIONFILTER)%>";
	var XSYSTEM_CHECKBROWSER = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_CHECKBROWSER)%>";
	var XSYSTEM_HOMEPAGE = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_HOMEPAGE)%>";
	var XSYSTEM_LOGINPAGE = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_LOGINPAGE)%>";
	var XSYSTEM_CONSOLE_IP = "<%=XSystemConfig.config().getProperty(XSystemConfig.XSYSTEM_CONSOLE_IP)%>";
	var GROOVE_VERSION = "<%=XSystemConfig.config().getProperty("GROOVE_VERSION")%>";
</script>
<script language="javascript"
	src="<%=context%>/resources/common/js/common.js"></script>
<script language="javascript"
	src="<%=context%>/resources/common/js/hashmap.js"></script>
<!-- ** CSS ** -->
<!-- base library -->
<link rel="stylesheet" type="text/css" href="<%=context%>/resources/ext3/resources/css/ext-all.css" />
<!-- ExtJS library: base/adapter -->
<script type="text/javascript" src="<%=context%>/resources/ext3/adapter/ext/ext-base.js"></script>
<!-- ExtJS library: all widgets -->
<script type="text/javascript" src="<%=context%>/resources/ext3/ext-all.js"></script>
<!-- ExtJS language -->
<script type="text/javascript" src="<%=context%>/resources/ext3/locale/ext-lang-zh_CN.js"></script>
<script>
var EXT_THEME = "<%=StringTool.checkString(XSystemConfig.config().getProperty("EXT_THEME"))%>";
if(EXT_THEME != ""){
Ext.util.CSS.swapStyleSheet('theme', context + '/resources/ext3/resources/css/' + EXT_THEME);
}
Ext.BLANK_IMAGE_URL = "<%=context%>/resources/ext3/resources/images/default/s.gif"; 
</script>
<script>
    var roles = new HashMap(); 
    <%
    	if(roleList != null && !roleList.isEmpty()){
    		for(int i = 0 ; i< roleList.size(); i++){
    			IRole role = (IRole)roleList.get(i);
    %>
    roles.put('<%=role.ikey()%>', '<%=role.iname()%>');
    <%
    		}
    	}
    %>
    
    <%
        if(headParamList != null && !headParamList.isEmpty()){
        	for(int i=0;i<headParamList.size();i++){
        		XWordbook wb = (XWordbook)headParamList.get(i);
        		String paramName = StringTool.checkString(wb.getID());
        		String paramValue = StringTool.checkString(wb.getName());
        		if(!paramName.equals("")){
    %>
    var <%=paramName%> = '<%=paramValue%>';
    <%
        	
        		}
        	}	
        }
    %>
</script>
<%}%>